iT邦幫忙

2023 iThome 鐵人賽

DAY 5
0
DevOps

SRE/K8S 碎碎念系列 第 5

D5 EKS Plugin

  • 分享至 

  • xImage
  •  

今天來分享一個小個案,讓大家知道 K8S 有趣的 plugin 用法

自從將 EKS 從 1.22 升級到 1.24 之後,發生了部署時 helm release 部署 appmesh controller 的問題,logs 如下

Error: current release manifest contains removed kubernetes api(s) for this kubernetes version and it is therefore unable to build the kubernetes objects for performing the diff. error from kubernetes: [unable to recognize "": no matches for kind "MutatingWebhookConfiguration" in version "admissionregistration.k8s.io/v1beta1", unable to recognize "": no matches for kind "ValidatingWebhookConfiguration" in version "admissionregistration.k8s.io/v1beta1"]
  on helm_release.tf line 191, in resource "helm_release" "appmesh_controller":
 191: resource "helm_release" "appmesh_controller" {
ERRO[2023-06-28T02:55:54Z] Application execution failedadmissionregistration.k8s.io/v1beta1

既然得到這個資訊,我們就來查一下 admissionregistration.k8s.io/v1beta1 到底是什麼,後來發現K8S升級到1.22後,已經將[admissionregistration.k8s.io/v1](http://admissionregistration.k8s.io/v1)beta1
改成 admissionregistration.k8s.io/v1 。但 Appmesh 還是在抓beta1。所以我們來到此服務調用他的檔案,卻發現他實際是用 admissionregistration.k8s.io/v1 。他從哪邊判斷到 v1beta1 不得而知,但我們後來找到了 plugin 解決這個問題

  • 安裝 mapkubeapis

    mapkubeapis 如何運作

    1. Helm v3 plugin
    2. 會 access 到 helm 管理的 cluster。概念就像是 kubectl access 到 kubeconfig files
    $ helm plugin install https://github.com/helm/helm-mapkubeapis
    Downloading and installing helm-mapkubeapis v0.1.0 ...
    https://github.com/helm/helm-mapkubeapis/releases/download/v0.1.0/helm-mapkubeapis_0.1.0_darwin_amd64.tar.gz
    Installed plugin: mapkubeapis/ca
    

    map.yaml 有對應到

    admissionregistration.k8s.io/v1beta1
    

    get value file

    my-appmesh-controller aws/appmesh-controller

    helm get values appmesh-controller -n appmesh-system -o yaml > beta-values.yaml
    

    Helm upgrade command

    helm upgrade appmesh-controller aws/appmesh-controller \
     --version 1.7 \
     -f "beta-values.yaml" \
     --wait \
     --namespace appmesh-system --dry-run
    
    helm mapkubeapis --dry-run --namespace appmesh-system appmesh-controller
    
    $ helm mapkubeapis --dry-run --namespace appmesh-system appmesh-controller
    2023/08/16 09:48:30 NOTE: This is in dry-run mode, the following actions will not be executed.
    2023/08/16 09:48:30 Run without --dry-run to take the actions described below:
    2023/08/16 09:48:30
    2023/08/16 09:48:30 Release 'appmesh-controller' will be checked for deprecated or removed Kubernetes APIs and will be updated if necessary to supported API versions.
    2023/08/16 09:48:30 Get release 'appmesh-controller' latest version.
    2023/08/16 09:48:34 Check release 'appmesh-controller' for deprecated or removed APIs...
    2023/08/16 09:48:34 Found 1 instances of deprecated or removed Kubernetes API:
    "apiVersion: admissionregistration.k8s.io/v1beta1
    kind: MutatingWebhookConfiguration
    "
    Supported API equivalent:
    "apiVersion: admissionregistration.k8s.io/v1
    kind: MutatingWebhookConfiguration
    "
    2023/08/16 09:48:34 Found 1 instances of deprecated or removed Kubernetes API:
    "apiVersion: admissionregistration.k8s.io/v1beta1
    kind: ValidatingWebhookConfiguration
    "
    Supported API equivalent:
    "apiVersion: admissionregistration.k8s.io/v1
    kind: ValidatingWebhookConfiguration
    "
    2023/08/16 09:48:34 Finished checking release 'appmesh-controller' for deprecated or removed APIs.
    2023/08/16 09:48:34 Deprecated or removed APIs exist, for release: appmesh-controller.
    2023/08/16 09:48:34 Map of release 'appmesh-controller' deprecated or removed APIs to supported versions, completed successfully.
    
    ---
    
    $ helm mapkubeapis --namespace appmesh-system appmesh-controller
    2023/08/16 10:29:37 Release 'appmesh-controller' will be checked for deprecated or removed Kubernetes APIs and will be updated if necessary to supported API versions.
    2023/08/16 10:29:37 Get release 'appmesh-controller' latest version.
    2023/08/16 10:29:41 Check release 'appmesh-controller' for deprecated or removed APIs...
    2023/08/16 10:29:41 Found 1 instances of deprecated or removed Kubernetes API:
    "apiVersion: admissionregistration.k8s.io/v1beta1
    kind: MutatingWebhookConfiguration
    "
    Supported API equivalent:
    "apiVersion: admissionregistration.k8s.io/v1
    kind: MutatingWebhookConfiguration
    "
    2023/08/16 10:29:41 Found 1 instances of deprecated or removed Kubernetes API:
    "apiVersion: admissionregistration.k8s.io/v1beta1
    kind: ValidatingWebhookConfiguration
    "
    Supported API equivalent:
    "apiVersion: admissionregistration.k8s.io/v1
    kind: ValidatingWebhookConfiguration
    "
    2023/08/16 10:29:41 Finished checking release 'appmesh-controller' for deprecated or removed APIs.
    2023/08/16 10:29:41 Deprecated or removed APIs exist, updating release: appmesh-controller.
    2023/08/16 10:29:41 Set status of release version 'appmesh-controller.v1' to 'superseded'.
    2023/08/16 10:29:43 Release version 'appmesh-controller.v1' updated successfully.
    2023/08/16 10:29:43 Add release version 'appmesh-controller.v2' with updated supported APIs.
    2023/08/16 10:29:45 Release version 'appmesh-controller.v2' added successfully.
    2023/08/16 10:29:45 Release 'appmesh-controller' with deprecated or removed APIs updated successfully to new version.
    2023/08/16 10:29:45 Map of release 'appmesh-controller' deprecated or removed APIs to supported versions, completed successfully.
    

    更新 api 後,helm 升級就成功了

    # 原本是
    
    helm upgrade appmesh-controller aws/appmesh-controller --dry-run \
     --version 1.4 \
     -f "stage-values.yaml" \
     --wait \
     --namespace appmesh-system
    Error: UPGRADE FAILED: unable to build kubernetes objects from current release manifest: [resource mapping not found for name: "appmesh-controller-mutating-webhook-configuration" namespace: "" from "": no matches for kind "MutatingWebhookConfiguration" in version "admissionregistration.k8s.io/v1beta1"
    ensure CRDs are installed first, resource mapping not found for name: "appmesh-controller-validating-webhook-configuration" namespace: "" from "": no matches for kind "ValidatingWebhookConfiguration" in version "admissionregistration.k8s.io/v1beta1"
    ensure CRDs are installed first]
    
    # 更新 API 之後
    
    $ helm upgrade appmesh-controller aws/appmesh-controller \
     --version 1.7 \
     -f "beta-values.yaml" \
     --wait \
     --namespace appmesh-system
    Release "appmesh-controller" has been upgraded. Happy Helming!
    NAME: appmesh-controller
    LAST DEPLOYED: Wed Aug 16 10:30:48 2023
    NAMESPACE: appmesh-system
    STATUS: deployed
    REVISION: 3
    TEST SUITE: None
    NOTES:
    AWS App Mesh controller installed!
    
    $ helm mapkubeapis --namespace appmesh-system appmesh-controller 
    2023/09/18 10:00:37 Release 'appmesh-controller' will be checked for deprecated or removed Kubernetes APIs and will be updated if necessary to supported API versions.
    2023/09/18 10:00:37 Get release 'appmesh-controller' latest version.
    2023/09/18 10:00:39 Check release 'appmesh-controller' for deprecated or removed APIs...
    2023/09/18 10:00:39 Found 1 instances of deprecated or removed Kubernetes API:
    "apiVersion: admissionregistration.k8s.io/v1beta1
    kind: MutatingWebhookConfiguration
    "
    Supported API equivalent:
    "apiVersion: admissionregistration.k8s.io/v1
    kind: MutatingWebhookConfiguration
    "
    2023/09/18 10:00:39 Found 1 instances of deprecated or removed Kubernetes API:
    "apiVersion: admissionregistration.k8s.io/v1beta1
    kind: ValidatingWebhookConfiguration
    "
    Supported API equivalent:
    "apiVersion: admissionregistration.k8s.io/v1
    kind: ValidatingWebhookConfiguration
    "
    2023/09/18 10:00:39 Finished checking release 'appmesh-controller' for deprecated or removed APIs.
    2023/09/18 10:00:39 Deprecated or removed APIs exist, updating release: appmesh-controller.
    2023/09/18 10:00:39 Set status of release version 'appmesh-controller.v5' to 'superseded'.
    2023/09/18 10:00:39 Release version 'appmesh-controller.v5' updated successfully.
    2023/09/18 10:00:39 Add release version 'appmesh-controller.v6' with updated supported APIs.
    2023/09/18 10:00:39 Release version 'appmesh-controller.v6' added successfully.
    2023/09/18 10:00:39 Release 'appmesh-controller' with deprecated or removed APIs updated successfully to new version.
    2023/09/18 10:00:39 Map of release 'appmesh-controller' deprecated or removed APIs to supported versions, completed successfully.
     $ helm mapkubeapis --dry-run --namespace appmesh-system appmesh-controller
    2023/09/18 10:00:50 NOTE: This is in dry-run mode, the following actions will not be executed.
    2023/09/18 10:00:50 Run without --dry-run to take the actions described below:
    2023/09/18 10:00:50
    2023/09/18 10:00:50 Release 'appmesh-controller' will be checked for deprecated or removed Kubernetes APIs and will be updated if necessary to supported API versions.
    2023/09/18 10:00:50 Get release 'appmesh-controller' latest version.
    2023/09/18 10:00:51 Check release 'appmesh-controller' for deprecated or removed APIs...
    2023/09/18 10:00:51 Finished checking release 'appmesh-controller' for deprecated or removed APIs.
    2023/09/18 10:00:51 Release 'appmesh-controller' has no deprecated or removed APIs.
    2023/09/18 10:00:51 Map of release 'appmesh-controller' deprecated or removed APIs to supported versions, completed successfully.
    
        $ helm upgrade appmesh-controller aws/appmesh-controller \              
     --version 1.7 \
     -f "beta-values.yaml" \
     --wait \
     --namespace appmesh-system
    Release "appmesh-controller" has been upgraded. Happy Helming!
    NAME: appmesh-controller
    LAST DEPLOYED: Mon Sep 18 10:01:28 2023
    NAMESPACE: appmesh-system
    STATUS: deployed
    REVISION: 7
    TEST SUITE: None
    NOTES:
    AWS App Mesh controller installed!
    

上一篇
D4 維運小工具設定
下一篇
Day 6 PDB, Permission, 跟 Deploy
系列文
SRE/K8S 碎碎念30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言